#!/usr/bin/env python
# -*- coding:utf-8 -*-

import pika

#durable
########################## 生产者 #########################

connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.136.8'))
channel = connection.channel()

channel.queue_declare(queue='hello', durable=True)  #开启持久化

channel.basic_publish(exchange='',
                      routing_key='hello',
                      body='Hello World!',
                      properties=pika.BasicProperties(
                          delivery_mode=2, # make message persistent
                      ))
print(" [x] Sent 'Hello World!'")
connection.close()